﻿//+------------------------------------------------------------------+
//|                                             MetaTrader 5 Web API |
//|                   Copyright 2001-2015, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
namespace MetaQuotes.MT5WebAPI.Common
  {
  /// <summary>
  /// position
  /// </summary>
  public class MTPosition
    {
    /// <summary>
    /// position types
    /// </summary>
    public enum EnPositionAction
      {
      POSITION_BUY = 0, // buy
      POSITION_SELL = 1, // sell
      //--- enumeration borders
      POSITION_FIRST = POSITION_BUY,
      POSITION_LAST = POSITION_SELL
      };
    /// <summary>
    /// activation modes
    /// </summary>
    public enum EnActivation
      {
      ACTIVATION_NONE = 0, // none
      ACTIVATION_SL = 1, // SL activated
      ACTIVATION_TP = 2, // TP activated
      ACTIVATION_STOPOUT = 3, // Stop-Out activated
      //--- enumeration borders
      ACTIVATION_FIRST = ACTIVATION_NONE,
      ACTIVATION_LAST = ACTIVATION_STOPOUT,
      };
    /// <summary>
    /// position activation flags
    /// </summary>
    public enum EnTradeActivationFlags
      {
      ACTIV_FLAGS_NO_LIMIT = 0x01,
      ACTIV_FLAGS_NO_STOP = 0x02,
      ACTIV_FLAGS_NO_SLIMIT = 0x04,
      ACTIV_FLAGS_NO_SL = 0x08,
      ACTIV_FLAGS_NO_TP = 0x10,
      ACTIV_FLAGS_NO_SO = 0x20,
      ACTIV_FLAGS_NO_EXPIRATION = 0x40,
      //--- 
      ACTIV_FLAGS_NONE = 0x00,
      ACTIV_FLAGS_ALL = ACTIV_FLAGS_NO_LIMIT | ACTIV_FLAGS_NO_STOP | ACTIV_FLAGS_NO_SLIMIT | ACTIV_FLAGS_NO_SL |
      ACTIV_FLAGS_NO_TP | ACTIV_FLAGS_NO_SO | ACTIV_FLAGS_NO_EXPIRATION
      };
    /// <summary>
    /// owner client login
    /// </summary>
    public ulong Login { get; set; }
    /// <summary>
    ///  position symbol
    /// </summary>
    public string Symbol { get; set; }
    /// <summary>
    /// EnPositionAction
    /// </summary>
    public EnPositionAction Action { get; set; }
    /// <summary>
    /// price digits
    /// </summary>
    public uint Digits { get; set; }
    /// <summary>
    /// currency digits
    /// </summary>
    public uint DigitsCurrency { get; set; }
    /// <summary>
    /// symbol contract size
    /// </summary>
    public double ContractSize { get; set; }
    /// <summary>
    /// position create time
    /// </summary>
    public ulong TimeCreate { get; set; }
    /// <summary>
    /// position last update time
    /// </summary>
    public ulong TimeUpdate { get; set; }
    /// <summary>
    /// position weighted average open price
    /// </summary>
    public double PriceOpen { get; set; }
    /// <summary>
    /// position current price
    /// </summary>
    public double PriceCurrent { get; set; }
    /// <summary>
    ///  position SL price
    /// </summary>
    public double PriceSL { get; set; }
    /// <summary>
    /// position TP price
    /// </summary>
    public double PriceTP { get; set; }
    /// <summary>
    /// position volume
    /// </summary>
    public ulong Volume { get; set; }
    /// <summary>
    /// position floating profit
    /// </summary>
    public double Profit { get; set; }
    /// <summary>
    ///  position accumulated swaps
    /// </summary>
    public double Storage { get; set; }
    /// <summary>
    /// commission
    /// </summary>
    public double Commission { get; set; }
    /// <summary>
    /// profit conversion rate (from symbol profit currency to deposit currency)
    /// </summary>
    public double RateProfit { get; set; }
    /// <summary>
    /// margin conversion rate (from symbol margin currency to deposit currency)
    /// </summary>
    public double RateMargin { get; set; }
    /// <summary>
    /// expert id (filled by expert advisor)
    /// </summary>
    public ulong ExpertID { get; set; }
    /// <summary>
    /// expert position id (filled by expert advisor)
    /// </summary>
    public ulong ExpertPositionID { get; set; }
    /// <summary>
    /// comment
    /// </summary>
    public string Comment { get; set; }
    /// <summary>
    /// order activation state
    /// </summary>
    public uint ActivationMode { get; set; }
    /// <summary>
    /// order activation time
    /// </summary>
    public ulong ActivationTime { get; set; }
    /// <summary>
    /// order activation price
    /// </summary>
    public double ActivationPrice { get; set; }
    /// <summary>
    /// order activation flags
    /// </summary>
    public uint ActivationFlags { get; set; }
    }
  }
